package com.ruoyi.aitcommon.vo;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.ruoyi.aitcommon.utils.AITConst;
import com.ruoyi.aitcommon.utils.ObjUtils;
import org.springframework.format.annotation.DateTimeFormat;

public class RuntimeVO {
//	错误级别越高,越严重
	public final static int LOGINFO=0;
	public final static int LOGWARN=1;
	public final static int LOGERR=2;

//	这里使用fastjson的注解无效,使用jackson的注解有效
//	可能是 框架使用的jackson,所以前后台传递用的jackson
	@JsonSerialize(using = ToStringSerializer.class)
	private long flowID;
	private String flowCode;
	private String flowName;
	private int status;//运行状态 0-关闭 1-运行
	private int logStatus=0;//日志状态 默认=INFO
	private String statusName;
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date startTime;
//	用于前端显示
	private String startTimeStr;
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date endTime;
//	用于前端显示
	private String endTimeStr;
//	这里使用fastjson的注解无效,使用jackson的注解有效,因为ruoyi框架使用的jackson
	@JsonSerialize(using = ToStringSerializer.class)
	private long runTime;
	private String method;
	private String errMsg;

	public int getLogStatus() {
		return logStatus;
	}

	public void setLogStatus(int logStatus) {
		this.logStatus = logStatus;
	}

	public String getErrMsg() {
		return errMsg;
	}

	public void setErrMsg(String errMsg) {
		if(errMsg.length()> AITConst.LOG_STRING_SIZE)
			errMsg= StrUtil.sub(errMsg,0,AITConst.LOG_STRING_SIZE);
		this.errMsg = errMsg;
	}

	public long getFlowID() {
		return flowID;
	}
	public void setFlowID(long flowID) {
		this.flowID = flowID;
	}
	public String getFlowCode() {
		return flowCode;
	}
	public void setFlowCode(String flowCode) {
		this.flowCode = flowCode;
	}
	public String getFlowName() {
		return flowName;
	}
	public void setFlowName(String flowName) {
		this.flowName = flowName;
	}
	public int getStatus() {
		return status;
	}
	public String getStatusName(){
		return statusName;
	}
	public void setStatusName(String statusName) {
		this.statusName = statusName;
	}
	public void setStatus(int status) {
		this.status = status;

		if(status==1)
			statusName="正在运行";
		else if(status==0){
			if(logStatus==LOGINFO)
				statusName="正常关闭";
			else if(logStatus==LOGWARN)
				statusName="警告关闭";
			else if(logStatus==LOGERR)
				statusName="异常关闭";
			else
				statusName="状态异常";
		}
		else
			statusName="状态异常";
	}
	public Date getStartTime() {
		return startTime;
	}
	public String getStartTimeStr(){
		return startTimeStr;
	}
	public void setStartTime(Date startTime) {
		this.startTime = startTime;
		this.startTimeStr= DateUtil.formatDateTime(startTime);
	}
	public Date getEndTime() {
		return endTime;
	}

	public String getEndTimeStr() {
		return endTimeStr;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
		this.endTimeStr=DateUtil.formatDateTime(endTime);
	}
	public long getRunTime() {
		return runTime;
	}
	public void setRunTime(long runTime) {
		this.runTime = runTime;
	}
	public String getMethod() {
		return method;
	}
	public void setMethod(String method) {
		this.method = method;
	}
	
	
}
